package com.beinhospital_sw21_h2_05.beinhospitalsw21h205.mapper;

import com.beinhospital_sw21_h2_05.beinhospitalsw21h205.entity.Medicine;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * MyBatis Mapper接口，用于与数据库表Medicine进行交互
 */
@Mapper
public interface MedicineMapper {

    /**
     * 根据药品名模糊查询药品信息
     * @param medicineName 药品名
     * @return 药品信息列表
     */
    List<Medicine> list(String medicineName);

    /**
     * 根据药品ID删除药品
     * @param medicineID 药品ID
     */
    @Delete("delete from Medicine where medicineID = #{medicineID}")
    void delete(Integer medicineID);

    /**
     * 插入新的药品信息
     * @param medicine 药品对象
     */
    @Insert("insert into Medicine(MedicineName, Price) values(#{MedicineName}, #{Price})")
    void insert(Medicine medicine);

    /**
     * 更新药品信息
     * @param medicine 药品对象
     */
    @Update("update Medicine set MedicineName = #{MedicineName}, Price = #{Price} where medicineID = #{medicineID}")
    void update(Medicine medicine);
}
